<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><span id="line-3"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.SysTools.Terminal</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.SysTools.Terminal.html#stderrSupportsAnsiColors"><span class="hs-identifier">stderrSupportsAnsiColors</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span class="hs-cpp">

#if defined(MIN_VERSION_terminfo)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Exception</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">catch</span><span class="hs-special">)</span><span>
</span><span id="line-9"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Maybe</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromMaybe</span><span class="hs-special">)</span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Console.Terminfo</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">SetupTermError</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">Terminal</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">getCapability</span><span class="hs-special">,</span><span>
</span><span id="line-11"></span><span>                                </span><span class="hs-identifier">setupTermFromEnv</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">termColors</span><span class="hs-special">)</span><span>
</span><span id="line-12"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Posix</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">queryTerminal</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">stdError</span><span class="hs-special">)</span><span class="hs-cpp">
#elif defined(mingw32_HOST_OS)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#catch"><span class="hs-identifier">catch</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.Base.html#try"><span class="hs-identifier">try</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-15"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator">(.|.)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator">(.&amp;.)</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.html#"><span class="hs-identifier">Foreign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier">peek</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier">with</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../Win32/src/Graphics.Win32.html#"><span class="hs-identifier">Graphics.Win32</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Win32</span></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.html#"><span class="hs-identifier">System.Win32</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Win32</span></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Unsafe.html#"><span class="hs-identifier">System.IO.Unsafe</span></a></span><span class="hs-cpp">

#if defined(mingw32_HOST_OS) &amp;&amp; !defined(WINAPI)
</span><span class="hs-cpp"># if defined(i386_HOST_ARCH)
</span><span class="hs-cpp">#  define WINAPI stdcall
</span><span class="hs-cpp"># elif defined(x86_64_HOST_ARCH)
</span><span class="hs-cpp">#  define WINAPI ccall
</span><span class="hs-cpp"># else
</span><span class="hs-cpp">#  error unknown architecture
</span><span class="hs-cpp"># endif
</span><span class="hs-cpp">#endif
</span><span>
</span><span id="line-33"></span><span class="hs-comment">-- | Does the controlling terminal support ANSI color sequences?</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- This memoized to avoid thread-safety issues in ncurses (see #17922).</span><span>
</span><span id="line-35"></span><span class="annot"><a href="GHC.SysTools.Terminal.html#stderrSupportsAnsiColors"><span class="hs-identifier hs-type">stderrSupportsAnsiColors</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-36"></span><span id="stderrSupportsAnsiColors"><span class="annot"><span class="annottext">stderrSupportsAnsiColors :: Bool
</span><a href="GHC.SysTools.Terminal.html#stderrSupportsAnsiColors"><span class="hs-identifier hs-var hs-var">stderrSupportsAnsiColors</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO Bool -&gt; Bool
forall a. IO a -&gt; a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafePerformIO"><span class="hs-identifier hs-var">unsafePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">IO Bool
</span><a href="GHC.SysTools.Terminal.html#stderrSupportsAnsiColors%27"><span class="hs-identifier hs-var">stderrSupportsAnsiColors'</span></a></span><span>
</span><span id="line-37"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.SysTools.Terminal.html#stderrSupportsAnsiColors"><span class="hs-pragma hs-type">stderrSupportsAnsiColors</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-comment">-- | Check if ANSI escape sequences can be used to control color in stderr.</span><span>
</span><span id="line-40"></span><span class="annot"><a href="GHC.SysTools.Terminal.html#stderrSupportsAnsiColors%27"><span class="hs-identifier hs-type">stderrSupportsAnsiColors'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-41"></span><span id="stderrSupportsAnsiColors%27"><span class="annot"><span class="annottext">stderrSupportsAnsiColors' :: IO Bool
</span><a href="GHC.SysTools.Terminal.html#stderrSupportsAnsiColors%27"><span class="hs-identifier hs-var hs-var">stderrSupportsAnsiColors'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span class="hs-cpp">
#if defined(MIN_VERSION_terminfo)
</span><span>    </span><span class="hs-identifier">stderr_available</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">queryTerminal</span><span> </span><span class="hs-identifier">stdError</span><span>
</span><span id="line-44"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">stderr_available</span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-45"></span><span>      </span><span class="hs-identifier">fmap</span><span> </span><span class="hs-identifier">termSupportsColors</span><span> </span><span class="hs-identifier">setupTermFromEnv</span><span>
</span><span id="line-46"></span><span>        </span><span class="hs-special">`</span><span class="hs-identifier">catch</span><span class="hs-special">`</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">SetupTermError</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pure</span><span> </span><span class="hs-identifier">False</span><span>
</span><span id="line-47"></span><span>    </span><span class="hs-keyword">else</span><span>
</span><span id="line-48"></span><span>      </span><span class="hs-identifier">pure</span><span> </span><span class="hs-identifier">False</span><span>
</span><span id="line-49"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-50"></span><span>    </span><span class="hs-identifier">termSupportsColors</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">Terminal</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-51"></span><span>    </span><span class="hs-identifier">termSupportsColors</span><span> </span><span class="hs-identifier">term</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">fromMaybe</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">getCapability</span><span> </span><span class="hs-identifier">term</span><span> </span><span class="hs-identifier">termColors</span><span class="hs-special">)</span><span> </span><span class="hs-operator">&gt;</span><span> </span><span class="hs-number">0</span><span class="hs-cpp">

#elif defined(mingw32_HOST_OS)
</span><span>  </span><span id="local-6989586621680776617"><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776617"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; IO HANDLE
</span><a href="../../Win32/src/Graphics.Win32.Misc.html#getStdHandle"><span class="hs-identifier hs-var">Win32.getStdHandle</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="../../Win32/src/Graphics.Win32.Misc.html#sTD_ERROR_HANDLE"><span class="hs-identifier hs-var">Win32.sTD_ERROR_HANDLE</span></a></span><span>
</span><span id="line-55"></span><span>         </span><span class="annot"><span class="annottext">IO HANDLE -&gt; (IOError -&gt; IO HANDLE) -&gt; IO HANDLE
forall e a. Exception e =&gt; IO a -&gt; (e -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#catch"><span class="hs-operator hs-var">`catch`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-type">IOError</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-56"></span><span>           </span><span class="annot"><span class="annottext">HANDLE -&gt; IO HANDLE
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="../../Win32/src/System.Win32.Types.html#nullHANDLE"><span class="hs-identifier hs-var">Win32.nullHANDLE</span></a></span><span>
</span><span id="line-57"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776617"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE -&gt; HANDLE -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="../../Win32/src/System.Win32.Types.html#nullHANDLE"><span class="hs-identifier hs-var">Win32.nullHANDLE</span></a></span><span>
</span><span id="line-58"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-59"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-60"></span><span>      </span><span id="local-6989586621680776613"><span class="annot"><span class="annottext">Either IOError DWORD
</span><a href="#local-6989586621680776613"><span class="hs-identifier hs-var">eMode</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO DWORD -&gt; IO (Either IOError DWORD)
forall e a. Exception e =&gt; IO a -&gt; IO (Either e a)
</span><a href="../../base/src/Control.Exception.Base.html#try"><span class="hs-identifier hs-var">try</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HANDLE -&gt; IO DWORD
</span><a href="GHC.SysTools.Terminal.html#getConsoleMode"><span class="hs-identifier hs-var">getConsoleMode</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776617"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either IOError DWORD
</span><a href="#local-6989586621680776613"><span class="hs-identifier hs-var">eMode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-62"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-type">IOError</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">HANDLE -&gt; IO Bool
</span><a href="../../Win32/src/System.Win32.MinTTY.html#isMinTTYHandle"><span class="hs-identifier hs-var">Win32.isMinTTYHandle</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776617"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-63"></span><span>                                 </span><span class="hs-comment">-- Check if the we're in a MinTTY terminal</span><span>
</span><span id="line-64"></span><span>                                 </span><span class="hs-comment">-- (e.g., Cygwin or MSYS2)</span><span>
</span><span id="line-65"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621680776610"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776610"><span class="hs-identifier hs-var">mode</span></a></span></span><span>
</span><span id="line-66"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; Bool
</span><a href="#local-6989586621680776609"><span class="hs-identifier hs-var">modeHasVTP</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776610"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-67"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">HANDLE -&gt; DWORD -&gt; IO Bool
</span><a href="#local-6989586621680776608"><span class="hs-identifier hs-var">enableVTP</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776617"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776610"><span class="hs-identifier hs-var">mode</span></a></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span>    </span><span class="annot"><a href="#local-6989586621680776608"><span class="hs-identifier hs-type">enableVTP</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#HANDLE"><span class="hs-identifier hs-type">Win32.HANDLE</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-72"></span><span>    </span><span id="local-6989586621680776608"><span class="annot"><span class="annottext">enableVTP :: HANDLE -&gt; DWORD -&gt; IO Bool
</span><a href="#local-6989586621680776608"><span class="hs-identifier hs-var hs-var">enableVTP</span></a></span></span><span> </span><span id="local-6989586621680776607"><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776607"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621680776606"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776606"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-73"></span><span>        </span><span class="annot"><span class="annottext">HANDLE -&gt; DWORD -&gt; IO ()
</span><a href="GHC.SysTools.Terminal.html#setConsoleMode"><span class="hs-identifier hs-var">setConsoleMode</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776607"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DWORD -&gt; DWORD
</span><a href="#local-6989586621680776604"><span class="hs-identifier hs-var">modeAddVTP</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776606"><span class="hs-identifier hs-var">mode</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span>        </span><span class="annot"><span class="annottext">DWORD -&gt; Bool
</span><a href="#local-6989586621680776609"><span class="hs-identifier hs-var">modeHasVTP</span></a></span><span> </span><span class="annot"><span class="annottext">(DWORD -&gt; Bool) -&gt; IO DWORD -&gt; IO Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE -&gt; IO DWORD
</span><a href="GHC.SysTools.Terminal.html#getConsoleMode"><span class="hs-identifier hs-var">getConsoleMode</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776607"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-75"></span><span>      </span><span class="annot"><span class="annottext">IO Bool -&gt; (IOError -&gt; IO Bool) -&gt; IO Bool
forall e a. Exception e =&gt; IO a -&gt; (e -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#catch"><span class="hs-operator hs-var">`catch`</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOError
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-type">IOError</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-76"></span><span>        </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span>    </span><span class="annot"><a href="#local-6989586621680776609"><span class="hs-identifier hs-type">modeHasVTP</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-79"></span><span>    </span><span id="local-6989586621680776609"><span class="annot"><span class="annottext">modeHasVTP :: DWORD -&gt; Bool
</span><a href="#local-6989586621680776609"><span class="hs-identifier hs-var hs-var">modeHasVTP</span></a></span></span><span> </span><span id="local-6989586621680776602"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776602"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776602"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DWORD -&gt; DWORD
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="GHC.SysTools.Terminal.html#eNABLE_VIRTUAL_TERMINAL_PROCESSING"><span class="hs-identifier hs-var">eNABLE_VIRTUAL_TERMINAL_PROCESSING</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DWORD -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span>    </span><span class="annot"><a href="#local-6989586621680776604"><span class="hs-identifier hs-type">modeAddVTP</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span>
</span><span id="line-82"></span><span>    </span><span id="local-6989586621680776604"><span class="annot"><span class="annottext">modeAddVTP :: DWORD -&gt; DWORD
</span><a href="#local-6989586621680776604"><span class="hs-identifier hs-var hs-var">modeAddVTP</span></a></span></span><span> </span><span id="local-6989586621680776599"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776599"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776599"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DWORD -&gt; DWORD
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="GHC.SysTools.Terminal.html#eNABLE_VIRTUAL_TERMINAL_PROCESSING"><span class="hs-identifier hs-var">eNABLE_VIRTUAL_TERMINAL_PROCESSING</span></a></span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="annot"><a href="GHC.SysTools.Terminal.html#eNABLE_VIRTUAL_TERMINAL_PROCESSING"><span class="hs-identifier hs-type">eNABLE_VIRTUAL_TERMINAL_PROCESSING</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span>
</span><span id="line-85"></span><span id="eNABLE_VIRTUAL_TERMINAL_PROCESSING"><span class="annot"><span class="annottext">eNABLE_VIRTUAL_TERMINAL_PROCESSING :: DWORD
</span><a href="GHC.SysTools.Terminal.html#eNABLE_VIRTUAL_TERMINAL_PROCESSING"><span class="hs-identifier hs-var hs-var">eNABLE_VIRTUAL_TERMINAL_PROCESSING</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0x0004</span></span><span>
</span><span id="line-86"></span><span>
</span><span id="line-87"></span><span class="annot"><a href="GHC.SysTools.Terminal.html#getConsoleMode"><span class="hs-identifier hs-type">getConsoleMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#HANDLE"><span class="hs-identifier hs-type">Win32.HANDLE</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span>
</span><span id="line-88"></span><span id="getConsoleMode"><span class="annot"><span class="annottext">getConsoleMode :: HANDLE -&gt; IO DWORD
</span><a href="GHC.SysTools.Terminal.html#getConsoleMode"><span class="hs-identifier hs-var hs-var">getConsoleMode</span></a></span></span><span> </span><span id="local-6989586621680776598"><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776598"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; (Ptr DWORD -&gt; IO DWORD) -&gt; IO DWORD
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">64</span></span><span> </span><span class="annot"><span class="annottext">((Ptr DWORD -&gt; IO DWORD) -&gt; IO DWORD)
-&gt; (Ptr DWORD -&gt; IO DWORD) -&gt; IO DWORD
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621680776597"><span class="annot"><span class="annottext">Ptr DWORD
</span><a href="#local-6989586621680776597"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-89"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; IO Bool -&gt; IO ()
</span><a href="../../Win32/src/System.Win32.Types.html#failIfFalse_"><span class="hs-identifier hs-var">Win32.failIfFalse_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GetConsoleMode&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HANDLE -&gt; Ptr DWORD -&gt; IO Bool
</span><a href="GHC.SysTools.Terminal.html#c_GetConsoleMode"><span class="hs-identifier hs-var">c_GetConsoleMode</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776598"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr DWORD
</span><a href="#local-6989586621680776597"><span class="hs-identifier hs-var">mode</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span>  </span><span class="annot"><span class="annottext">Ptr DWORD -&gt; IO DWORD
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr DWORD
</span><a href="#local-6989586621680776597"><span class="hs-identifier hs-var">mode</span></a></span><span>
</span><span id="line-91"></span><span>
</span><span id="line-92"></span><span class="annot"><a href="GHC.SysTools.Terminal.html#setConsoleMode"><span class="hs-identifier hs-type">setConsoleMode</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#HANDLE"><span class="hs-identifier hs-type">Win32.HANDLE</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span id="setConsoleMode"><span class="annot"><span class="annottext">setConsoleMode :: HANDLE -&gt; DWORD -&gt; IO ()
</span><a href="GHC.SysTools.Terminal.html#setConsoleMode"><span class="hs-identifier hs-var hs-var">setConsoleMode</span></a></span></span><span> </span><span id="local-6989586621680776594"><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776594"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621680776593"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776593"><span class="hs-identifier hs-var">mode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-94"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; IO Bool -&gt; IO ()
</span><a href="../../Win32/src/System.Win32.Types.html#failIfFalse_"><span class="hs-identifier hs-var">Win32.failIfFalse_</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SetConsoleMode&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HANDLE -&gt; DWORD -&gt; IO Bool
</span><a href="GHC.SysTools.Terminal.html#c_SetConsoleMode"><span class="hs-identifier hs-var">c_SetConsoleMode</span></a></span><span> </span><span class="annot"><span class="annottext">HANDLE
</span><a href="#local-6989586621680776594"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621680776593"><span class="hs-identifier hs-var">mode</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINAPI</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetConsoleMode&quot;</span><span id="c_GetConsoleMode"><span> </span></span><span class="hs-identifier">c_GetConsoleMode</span><span>
</span><span id="line-97"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#HANDLE"><span class="hs-identifier hs-type">Win32.HANDLE</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#BOOL"><span class="hs-identifier hs-type">Win32.BOOL</span></a></span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINAPI</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h SetConsoleMode&quot;</span><span id="c_SetConsoleMode"><span> </span></span><span class="hs-identifier">c_SetConsoleMode</span><span>
</span><span id="line-100"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#HANDLE"><span class="hs-identifier hs-type">Win32.HANDLE</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#DWORD"><span class="hs-identifier hs-type">Win32.DWORD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../Win32/src/System.Win32.Types.html#BOOL"><span class="hs-identifier hs-type">Win32.BOOL</span></a></span><span class="hs-cpp">

#else
</span><span>   </span><span class="hs-identifier">pure</span><span> </span><span class="hs-identifier">False</span><span class="hs-cpp">
#endif
</span></pre></body></html>